function hexToRGB(hex: string): [number, number, number] {
  const r = Number.parseInt(hex.slice(1, 3), 16)
  const g = Number.parseInt(hex.slice(3, 5), 16)
  const b = Number.parseInt(hex.slice(5, 7), 16)
  return [r, g, b]
}

function rgbToHex(r: number, g: number, b: number): string {
  return `#${r.toString(16).padStart(2, "0")}${g.toString(16).padStart(2, "0")}${b.toString(16).padStart(2, "0")}`
}

function adjustColor([r, g, b]: [number, number, number], factor: number): [number, number, number] {
  return [
    Math.min(255, Math.max(0, r + factor)),
    Math.min(255, Math.max(0, g + factor)),
    Math.min(255, Math.max(0, b + factor))
  ]
}

function generateSuccessColors(baseColor: string): Record<string, string> {
  const baseRGB = hexToRGB(baseColor)
  return {
    "--el-color-success": baseColor,
    "--el-color-success-light-3": rgbToHex(...adjustColor(baseRGB, 50)),
    "--el-color-success-light-5": rgbToHex(...adjustColor(baseRGB, 100)),
    "--el-color-success-light-7": rgbToHex(...adjustColor(baseRGB, 150)),
    "--el-color-success-light-8": rgbToHex(...adjustColor(baseRGB, 180)),
    "--el-color-success-light-9": rgbToHex(...adjustColor(baseRGB, 210)),
    "--el-color-success-dark-2": rgbToHex(...adjustColor(baseRGB, -30))
  }
}

const successColors = generateSuccessColors("#3ac295")
